<{include file="app/header.tpl"}>


<script>
function address_set_default(item, addrId)
{
    url = '/api/address/set_default/' + addrId;
    $.get(url, function (o) {
        if (o.status == 0)
        {
            $('.addrStat').removeClass('active');
            $(item).addClass('active');
            //
        }
    }, 'json')
}

function url_add_param (item, key, val)
{
    var url = $(item).attr('href');
    url = url.replace(/&addressId=\d+/g, '');
    if (/\?/.test(url))
    {
        url = url + '&' + key + '=' + val;
    }
    else
    {
        url = url + '?key' + '=' + val;
    }
    $(item).attr('href', url);
}
</script>

<ul class="user-address-list">
    <{foreach from=$addressList item="addr"}>
        <li class="li">
            <p class="one">
                <span class="name"><{$addr.userName}></span>
                <span class="number"><{$addr.telNumber}></span>
            </p>
            <p class="two">
                <{$addr.proviceName}><{$addr.cityName}><{$addr.countryName}><{$addr.detailInfo}>
            </p>
            <p class="three fix">
                <label class="shezhi-default">
                    <input type="radio"  <{if $addr.isDefault}>checked<{/if}> name="address" id="">
                    <span class="addrStat <{if $addr.isDefault}>active<{/if}>" onclick="address_set_default(this, <{$addr.id}>)">设为默认地址</span></label>
                <a class="del" href="/address/del/<{$addr.id}>">删除</a>
                <a class="edit" href="/address/edit/<{$addr.id}>">编辑</a>
                <a class="shiyong" href="<{$refer}>" onclick="url_add_param(this, 'addressId', <{$addr.id}>)">使用</a>
            </p>
        </li>
    <{/foreach}>
</ul>

<div class="user-address-add">
    <{if !$addressList}>
        <p class="prompt">
            <img src="/resource/app/imgs/all_empty.png" class="img" alt="">
            暂无地址
        </p>
    <{/if}>
    <a class="a" href="/address/add">添加新地址</a>
</div>

<{include file="app/footer.tpl"}>
